/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package Form;

import BLL.BLLOrder;
import BLL.BLLOrderDetail;
import DTO.DTOOrder;
import java.awt.Dimension;
import java.awt.Toolkit;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.util.Calendar;
import java.util.Date;
import java.util.Objects;
import javax.swing.DefaultCellEditor;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.JTable;
import javax.swing.table.DefaultTableModel;
import javax.swing.table.TableColumn;

/**
 *
 * @author Pham
 */
public class JPanelManageOrder extends javax.swing.JPanel {
    BLLOrder bllOrd;
    BLLOrderDetail bllDetail;
    JTable table;
    /**
     * Creates new form JPanelManageOrder
     */
    public JPanelManageOrder() {
        bllOrd = new BLLOrder();
        bllDetail = new BLLOrderDetail();
        loadData();
        initComponents();
        
        
//        setState(table, table.getColumnModel().getColumn(6));
        cbState.addItem(new MyState(-1, "Toàn bộ"));
        cbState.addItem(new MyState(0, "Mới tạo"));
        cbState.addItem(new MyState(1, "Chờ xử lý"));
        cbState.addItem(new MyState(2, "Đã xuất hàng"));
    }
    
    /**
     * This method is called from within the constructor to initialize the form.
     * WARNING: Do NOT modify this code. The content of this method is always
     * regenerated by the Form Editor.
     */
    
    //method load data
    private void loadData()
    {
        DefaultTableModel model = new DefaultTableModel();
        String[] cols = {"Mã", "Ngày đặt", "Người nhận",
                                        "Địa chỉ","Số ĐT",
                                        "Email", "Trạng thái"};
        model.setColumnIdentifiers(cols);
        for(DTOOrder dtoOder : bllOrd.getOrders()){
            String state = "";
            if(dtoOder.getOrderState() == 0)
                state = "Mới tạo";
            else if(dtoOder.getOrderState() == 1)
                state = "Chờ xử lý";
            else
                state = "Đã xuất hàng";
            model.addRow(new Object[]{dtoOder.getOrderId(), dtoOder.getOrderDateCreated(),
                                    dtoOder.getOrderGuessName(), dtoOder.getOrderGuessAddress(),
                                    dtoOder.getOrderGuessPhone(), dtoOder.getOrderGuessEmail(), state});
        }
        
        table = new JTable();
        table.setModel(model);
        table.setAutoCreateRowSorter(true);
        table.setPreferredSize(new Dimension(900, 400));
    }
    
    //
    private void setState(JTable table, TableColumn col)
    {
        JComboBox comboState = new JComboBox();
        comboState.addItem(new MyState(0, "Mới tạo"));
        comboState.addItem(new MyState(1, "Chờ xử lý"));
        comboState.addItem(new MyState(2, "Đã xác nhận"));
        col.setCellEditor(new DefaultCellEditor(comboState));
        comboState.addActionListener(new ActionListener() {

            @Override
            public void actionPerformed(ActionEvent e) {
                cbStateActionPerformed(e);
            }
        });
    }
    
    
    @SuppressWarnings("unchecked")
    // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
    private void initComponents() {

        jPanel1 = new javax.swing.JPanel();
        jPanel2 = new javax.swing.JPanel();
        btnViewAll = new javax.swing.JButton();
        jScrollPane1 = new javax.swing.JScrollPane(table);
        btnViewDetail = new javax.swing.JButton();
        jPanel3 = new javax.swing.JPanel();
        jLabel2 = new javax.swing.JLabel();
        dateChooseFrom = new com.toedter.calendar.JDateChooser();
        jLabel4 = new javax.swing.JLabel();
        cbState = new javax.swing.JComboBox();
        btnFilter = new javax.swing.JButton();
        jLabel3 = new javax.swing.JLabel();
        dateChooseTo = new com.toedter.calendar.JDateChooser();
        btnRequestExport = new javax.swing.JButton();
        btnCreateOrder = new javax.swing.JButton();
        btnCreateOrder1 = new javax.swing.JButton();

        jPanel2.setBorder(javax.swing.BorderFactory.createTitledBorder(null, "Danh sách đơn hàng", javax.swing.border.TitledBorder.DEFAULT_JUSTIFICATION, javax.swing.border.TitledBorder.DEFAULT_POSITION, new java.awt.Font("Arial", 0, 12), new java.awt.Color(0, 102, 102))); // NOI18N

        btnViewAll.setBackground(new java.awt.Color(204, 204, 255));
        btnViewAll.setText("Xem toàn bộ đơn hàng");
        btnViewAll.setPreferredSize(new java.awt.Dimension(145, 30));
        btnViewAll.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnViewAllActionPerformed(evt);
            }
        });

        jScrollPane1.setToolTipText("");
        jScrollPane1.setAutoscrolls(true);

        btnViewDetail.setBackground(new java.awt.Color(204, 204, 255));
        btnViewDetail.setForeground(new java.awt.Color(0, 51, 153));
        btnViewDetail.setText("Xem chi tiết đơn hàng");
        btnViewDetail.setDebugGraphicsOptions(javax.swing.DebugGraphics.BUFFERED_OPTION);
        btnViewDetail.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnViewDetailActionPerformed(evt);
            }
        });

        jPanel3.setBorder(javax.swing.BorderFactory.createLineBorder(new java.awt.Color(102, 102, 102)));

        jLabel2.setText("Lọc đơn hàng từ ngày");

        dateChooseFrom.addPropertyChangeListener(new java.beans.PropertyChangeListener() {
            public void propertyChange(java.beans.PropertyChangeEvent evt) {
                dateChooseFromPropertyChange(evt);
            }
        });

        jLabel4.setText("Lọc theo trạng thái");

        btnFilter.setBackground(new java.awt.Color(0, 153, 51));
        btnFilter.setText("Lọc");
        btnFilter.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnFilterActionPerformed(evt);
            }
        });

        jLabel3.setText("Đến ngày");

        javax.swing.GroupLayout jPanel3Layout = new javax.swing.GroupLayout(jPanel3);
        jPanel3.setLayout(jPanel3Layout);
        jPanel3Layout.setHorizontalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jLabel2)
                    .addComponent(jLabel4))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addComponent(dateChooseFrom, javax.swing.GroupLayout.PREFERRED_SIZE, 150, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addGap(18, 18, 18)
                        .addComponent(jLabel3)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(dateChooseTo, javax.swing.GroupLayout.PREFERRED_SIZE, 145, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addComponent(cbState, javax.swing.GroupLayout.PREFERRED_SIZE, 130, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addGap(32, 32, 32)
                .addComponent(btnFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 110, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap())
        );
        jPanel3Layout.setVerticalGroup(
            jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel3Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addGroup(jPanel3Layout.createSequentialGroup()
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(jLabel2)
                            .addComponent(dateChooseFrom, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel3)
                            .addComponent(dateChooseTo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addGroup(jPanel3Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.CENTER)
                            .addComponent(cbState, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(jLabel4)))
                    .addComponent(btnFilter, javax.swing.GroupLayout.PREFERRED_SIZE, 34, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addContainerGap(14, Short.MAX_VALUE))
        );

        btnRequestExport.setBackground(new java.awt.Color(102, 102, 255));
        btnRequestExport.setForeground(new java.awt.Color(255, 255, 255));
        btnRequestExport.setText("Xuất hàng");
        btnRequestExport.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnRequestExportActionPerformed(evt);
            }
        });

        btnCreateOrder.setText("Tạo đơn hàng");
        btnCreateOrder.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCreateOrderActionPerformed(evt);
            }
        });

        btnCreateOrder1.setText("Hủy đơn hàng");
        btnCreateOrder1.addActionListener(new java.awt.event.ActionListener() {
            public void actionPerformed(java.awt.event.ActionEvent evt) {
                btnCreateOrder1ActionPerformed(evt);
            }
        });

        javax.swing.GroupLayout jPanel2Layout = new javax.swing.GroupLayout(jPanel2);
        jPanel2.setLayout(jPanel2Layout);
        jPanel2Layout.setHorizontalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addContainerGap()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
                    .addComponent(jScrollPane1)
                    .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel2Layout.createSequentialGroup()
                        .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 68, Short.MAX_VALUE)
                        .addComponent(btnViewAll, javax.swing.GroupLayout.PREFERRED_SIZE, 160, javax.swing.GroupLayout.PREFERRED_SIZE))
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addComponent(btnCreateOrder)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnCreateOrder1)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                        .addComponent(btnRequestExport)
                        .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                        .addComponent(btnViewDetail)))
                .addContainerGap())
        );
        jPanel2Layout.setVerticalGroup(
            jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel2Layout.createSequentialGroup()
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
                    .addComponent(jPanel3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addComponent(btnViewAll, javax.swing.GroupLayout.PREFERRED_SIZE, 35, javax.swing.GroupLayout.PREFERRED_SIZE))
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addComponent(jScrollPane1, javax.swing.GroupLayout.PREFERRED_SIZE, 291, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
                .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                    .addComponent(btnViewDetail, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                    .addGroup(jPanel2Layout.createSequentialGroup()
                        .addGroup(jPanel2Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
                            .addComponent(btnCreateOrder, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnCreateOrder1, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE)
                            .addComponent(btnRequestExport, javax.swing.GroupLayout.PREFERRED_SIZE, 37, javax.swing.GroupLayout.PREFERRED_SIZE))
                        .addGap(0, 0, Short.MAX_VALUE)))
                .addContainerGap())
        );

        javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
        jPanel1.setLayout(jPanel1Layout);
        jPanel1Layout.setHorizontalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
                .addContainerGap())
        );
        jPanel1Layout.setVerticalGroup(
            jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(jPanel1Layout.createSequentialGroup()
                .addContainerGap()
                .addComponent(jPanel2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addContainerGap(91, Short.MAX_VALUE))
        );

        javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
        this.setLayout(layout);
        layout.setHorizontalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
        );
        layout.setVerticalGroup(
            layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
            .addGroup(layout.createSequentialGroup()
                .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
                .addGap(0, 0, Short.MAX_VALUE))
        );
    }// </editor-fold>//GEN-END:initComponents

    //method action view all order
    private void btnViewAllActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewAllActionPerformed
        try{
            DefaultTableModel tbModel = (DefaultTableModel)table.getModel();
            int countRow = tbModel.getRowCount();
            for(int i = countRow - 1; i >= 0; i--){
                tbModel.removeRow(i);
            }
            
            for(DTOOrder dtoOder : bllOrd.getOrders()){
                    String state = "";
                if(dtoOder.getOrderState() == 0)
                    state = "Mới tạo";
                else if(dtoOder.getOrderState() == 1)
                    state = "Chờ xử lý";
                else
                    state = "Đã xuất hàng";
                tbModel.addRow(new Object[]{dtoOder.getOrderId(), dtoOder.getOrderDateCreated(),
                                    dtoOder.getOrderGuessName(), dtoOder.getOrderGuessAddress(),
                                    dtoOder.getOrderGuessPhone(), dtoOder.getOrderGuessEmail(), state});
            }
        }
        catch(Exception ex){
            JOptionPane.showMessageDialog(null, "Error");
        }
    }//GEN-LAST:event_btnViewAllActionPerformed

    //method action filter with state and date create
    private void btnFilterActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnFilterActionPerformed
        try{
            Date dateFrom = dateChooseFrom.getDate();
            Date dateTo = dateChooseTo.getDate();
            MyState cbmodel = (MyState)cbState.getSelectedItem();
            DefaultTableModel tbModel = (DefaultTableModel)table.getModel();
            int countRow = tbModel.getRowCount();
            for(int i = countRow - 1; i >= 0; i--){
                tbModel.removeRow(i);
            }
            
            for(DTOOrder dtoOrder : bllOrd.filterOrder(dateFrom, dateTo, cbmodel.getId())){
                String state = "";
                if(dtoOrder.getOrderState() == 0)
                    state = "Mới tạo";
                else if(dtoOrder.getOrderState() == 1)
                    state = "Chờ xử lý";
                else
                    state = "Đã xuất hàng";
                tbModel.addRow(new Object[]{dtoOrder.getOrderId(), dtoOrder.getOrderDateCreated(),
                                    dtoOrder.getOrderGuessName(), dtoOrder.getOrderGuessAddress(),
                                    dtoOrder.getOrderGuessPhone(), dtoOrder.getOrderGuessEmail(), state});
            }
        }
        catch(Exception ex){
            JOptionPane.showMessageDialog(null, "Error Filter");
        }
    }//GEN-LAST:event_btnFilterActionPerformed

    //method action view detail of order with orderId
    private void btnViewDetailActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnViewDetailActionPerformed
        try{
            int rowSelect = table.getSelectedRow();
            if(rowSelect > -1){
                String OrderID = (String)table.getValueAt(table.getSelectedRow(), 0);
                JDialogOrderDetail detail = new JDialogOrderDetail(null, true, OrderID);
                Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
                detail.setLocation((dim.width - detail.getWidth())/2, (dim.height - detail.getHeight())/2);
                detail.setVisible(true);
            }
            else{
                JOptionPane.showMessageDialog(null, "Chọn đơn hàng cần xem");
            }
        }
        catch(Exception ex){
            JOptionPane.showMessageDialog(null, "Error show detail");
        }
    }//GEN-LAST:event_btnViewDetailActionPerformed

    //method action send request export
    private void btnRequestExportActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnRequestExportActionPerformed
        try{
            int rowSelect = table.getSelectedRow();
            if(rowSelect > -1){
                String OrderID = (String)table.getValueAt(table.getSelectedRow(), 0);
                DTOOrder dtoOrd = bllOrd.getOrderbyId(OrderID);
                if(bllOrd.exeExport(dtoOrd)){
                    JOptionPane.showMessageDialog(null, "Đã xuất hàng");
                    table.setValueAt("Đã xuất hàng", table.getSelectedRow(), 6);
                }
                else
                {
                    JOptionPane.showMessageDialog(null, "Không thể xuất hàng");
                    dtoOrd.setOrderState(1);
                    Date currentDateTime = new Date();
                    dtoOrd.setDateExport(currentDateTime);
                    if(bllOrd.updateState(dtoOrd))
                        table.setValueAt("Chờ xử lý", table.getSelectedRow(), 6);
                }
            }
            else{
                JOptionPane.showMessageDialog(null, "Chọn đơn hàng cần thực hiện");
            }
            
        }
        catch(Exception ex)
        {
            JOptionPane.showMessageDialog(null, "Lỗi, không thể xuất hàng");
        }
    }//GEN-LAST:event_btnRequestExportActionPerformed

    private void dateChooseFromPropertyChange(java.beans.PropertyChangeEvent evt) {//GEN-FIRST:event_dateChooseFromPropertyChange
        try {
            Date getDate = dateChooseFrom.getDate();
            Calendar cal = Calendar.getInstance();
            cal.setTime(getDate);
            cal.add(Calendar.DATE, 1);
            Date setDate  = cal.getTime();
            dateChooseTo.setMinSelectableDate(setDate);
        } 
        catch (Exception ex) {
            System.err.println(ex.getMessage());
        }
//        dateChooseTo.setMinSelectableDate(dateChooseFrom.getDate());
    }//GEN-LAST:event_dateChooseFromPropertyChange

    //method action create new order
    private void btnCreateOrderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCreateOrderActionPerformed
        JDialogAddOrder dialog = new JDialogAddOrder(null, true);
        Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
        dialog.setLocation((dim.width - dialog.getWidth())/2, (dim.height - dialog.getHeight())/2);
        dialog.setVisible(true);
    }//GEN-LAST:event_btnCreateOrderActionPerformed

    //method action delete order
    private void btnCreateOrder1ActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCreateOrder1ActionPerformed
        try{
            int[] rows = table.getSelectedRows();
            if(rows.length > 0)
            {
                int quesstion = JOptionPane.showConfirmDialog(null, "Bạn có chắc muốn xóa", "Thông báo", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE);
                if(quesstion == JOptionPane.YES_OPTION)
                {
                    String orderId = "";
                    DefaultTableModel modelOrd = (DefaultTableModel)table.getModel();
                    for(int i = rows.length - 1; i >= 0; i--)
                    {
                        orderId = table.getValueAt(i, 0).toString();
                        if(!"".equals(orderId))
                        {
                            if(bllDetail.deleteOrderDetail(orderId))
                                if(bllOrd.deleteOrder(orderId))
                                {
                                    modelOrd.removeRow(i);
                                    JOptionPane.showMessageDialog(null, "Đã hủy đơn hàng");
                                }
                        }
                    }
                }
            }
            else
                JOptionPane.showMessageDialog(null, "Bạn hãy chọn đơn hàng muốn hủy");
        }
        catch(Exception ex)
        {
            JOptionPane.showMessageDialog(null, "Lỗi: không thể xóa đơn hàng");
        }
    }//GEN-LAST:event_btnCreateOrder1ActionPerformed
    
    //method action create export
    private void cbStateActionPerformed(java.awt.event.ActionEvent evt)
    {
        try{
            MyState state = (MyState)cbState.getSelectedItem();
            JOptionPane.showMessageDialog(null, state.getId());
        }
        catch(Exception ex){
            JOptionPane.showMessageDialog(null, "Error create export");
        }
    }
    class MyState{
        int id;
        String state;

        public int getId() {
            return id;
        }

        public String getState() {
            return state;
        }

        public void setId(int id) {
            this.id = id;
        }

        public void setState(String state) {
            this.state = state;
        }

        public MyState(int id, String state) {
            this.id = id;
            this.state = state;
        }

        public MyState() {
        }
        
        
        @Override
        public String toString(){
            return this.state;
        }
        
        @Override
        public boolean equals(Object ob){
            if(ob instanceof MyState)
            {
                MyState mystate = (MyState)ob;
                return mystate.state.equals(this.state);
            }
            return false;
        }

        @Override
        public int hashCode() {
            int hash = 3;
            hash = 53 * hash + Objects.hashCode(this.state);
            return hash;
        }
    }
    // Variables declaration - do not modify//GEN-BEGIN:variables
    private javax.swing.JButton btnCreateOrder;
    private javax.swing.JButton btnCreateOrder1;
    private javax.swing.JButton btnFilter;
    private javax.swing.JButton btnRequestExport;
    private javax.swing.JButton btnViewAll;
    private javax.swing.JButton btnViewDetail;
    private javax.swing.JComboBox cbState;
    private com.toedter.calendar.JDateChooser dateChooseFrom;
    private com.toedter.calendar.JDateChooser dateChooseTo;
    private javax.swing.JLabel jLabel2;
    private javax.swing.JLabel jLabel3;
    private javax.swing.JLabel jLabel4;
    private javax.swing.JPanel jPanel1;
    private javax.swing.JPanel jPanel2;
    private javax.swing.JPanel jPanel3;
    private javax.swing.JScrollPane jScrollPane1;
    // End of variables declaration//GEN-END:variables
}
